<?php
/***************************************************************************
 *
 *   copyright            : (C) 2005 Winds of Storm
 *
 *   $Id: whoson-lite.php,v 1.6 2005/12/13 20:07:45 nathan Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

require("config.php");
require($libdir . "init." . $phpEx);
require($libdir . "chat_functs." . $phpEx);

print("<link rel=\"stylesheet\" href=\"chat.css\" type=\"text/css\">\n");
print("<body class=whoson>");
print("<title>People Chatting</title>\n");

$sql		= "SELECT * FROM {$dbprefix}rooms WHERE room_id={$_REQUEST['room_id']}";
if ($result = $db->sql_query($sql)) {
	while ($row = $db->sql_fetchrow($result)) {
		$sql2		= "SELECT * FROM {$dbprefix}sessions WHERE room_id={$row['room_id']}";
		$res2		= $db->sql_query($sql2);
		print("<b>{$row['room_name']} [" . $db->sql_numrows($res2) . "]</b><br />\n");
		$count		= 0;
		while ($row2 = $db->sql_fetchrow($res2)) {
			if ($row2['idle_timer'] > 300) {
				$idle	= " <i>idle " . number_format($row2['idle_timer'] / 60, 0) . " minutes</i>";
			} else {
				$idle	= '';
			}

			if ($row2['moderator']) {
				$mod	= ' <i>(Moderator)</i>';
			} else {
				$mod	= '';
			}

			$online[$count++] = "<a href=$profile_url{$row2['user_id']}>{$row2['username']}</a>";
		}

		for ($i = 0; $i < $count; $i++) {
			print($online[$i]);
			if ($i < ($count - 1)) {
				print(", ");
			}
		}
	}
}

?>
